home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1995 January / 1995-01b.d64 / value of money (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  6KB  |  208 lines

  1. 5 rem copyright 1995 - compute publications intl ltd - all rights reserved
  2. 10 dc=1
  3. 20 space$=""
  4. 30 cur=1
  5. 40 d$="discrete  "
  6. 50 c$="continuous"
  7. 60 printchr$(147)
  8. 70 rem the value of money
  9. 80 poke 53280,0:poke53281,0
  10. 90 print"[176][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][174]":n=1:gosub 100:goto 130
  11. 100 fori=1ton
  12. 110 print"[194]";space$;"[194]"
  13. 120 next i :return
  14. 130 print"[171][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][179]"
  15. 140 n=16:gosub 100
  16. 150 print"[171][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][179]"
  17. 160 n=1:gosub 100
  18. 170 print"[173][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][189]":print"[145][145][159]c[146]ompounding: ";
  19. 180 rem
  20. 190 print"";
  21. 200 if dc=1 thenprint"";d$
  22. 210 if dc=0 thenprint"";c$
  23. 220 print"[159]the value of money"
  24. 230 ifcur=1thenprint"   *compound amount        *":goto250
  25. 240 print"   compound amount"
  26. 250 print"   present worth"
  27. 260 print"   sinking fund factor"
  28. 270 print"   series compound amount"
  29. 280 print"   capital recovery"
  30. 290 print" [160] series present worth"
  31. 300 print"   arithmetic gradient"
  32. 310 print"q[146]uith[146]elpspace[146]"
  33. 320 a=0:g=0:p=0:f=0:rem these are reset-if nothing is entered,goes back to menu
  34. 330 geta$:ifa$<>"" anda$<>"[145]"anda$<>"h"anda$<>"q"anda$<>" "anda$<>"c"then 330
  35. 340 ifa$="c" ora$="q"ora$=" " then gosub 570
  36. 350 ifa$="c"anddc=1thendc=0:goto180
  37. 360 ifa$="c" anddc=0thendc=1:goto180
  38. 370 if a$="h" then gosub 1930
  39. 380 if a$="q" then end
  40. 390 if a$="[145]" and cur>1 then cur=cur-1:gosub430:gosub480:goto180
  41. 400 ifa$=" "then gosub 590:goto 180
  42. 410 ifa$=""and cur<7then cur=cur+1:gosub430:gosub480:goto180
  43. 420 goto 330
  44. 430 rem clear asterisks
  45. 440 print"  "
  46. 450 fort=1to6:print"  "
  47. 460 next t
  48. 470 return
  49. 480 rem put asterisks up
  50. 490 if cur<>1 then print"":goto 510
  51. 500 print"**"
  52. 510 fort=2to7
  53. 520 if t=curthen print"**":goto 540
  54. 530 print"  "
  55. 540 next t
  56. 550 rem bell  routine
  57. 560 return
  58. 570 poke54296,21:poke54277,9:poke54278,0:poke54273,48:poke54276,32:poke54276,33
  59. 580 return
  60. 590 rem calculation routine
  61. 600 printchr$(147)
  62. 610 if cur=1thengoto680
  63. 620 if cur=2thengoto840
  64. 630 if cur=3thengoto1000
  65. 640 if cur=4thengoto1160
  66. 650 if cur=5thengoto1360
  67. 660 if cur=6thengoto1520
  68. 670 if cur=7thengoto1720
  69. 680 rem
  70. 690 print"compound amount: ";
  71. 700 ifdc=1then printd$;""
  72. 710 ifdc<>1thenprintc$;""
  73. 720 input"present amount ($): ";p:print
  74. 730 ifp=0then goto20
  75. 740 input"interest rate per period (%): ";pr:print
  76. 750 input"time period: ";per
  77. 760 if dc=1 then f=p*((1+pr/100)^per)
  78. 770 ifdc<>1 thenr=(pr/100)
  79. 780 ifdc<>1 then f=p*(exp(r*per)*exp(r)-1)/(r*exp(r))
  80. 790 print"the future worth[160](compound amount) is"
  81. 800 print "$";f
  82. 810 print"press any key to continue"
  83. 820 geta$:ifa$=""then820
  84. 830 goto20
  85. 840 rem
  86. 850 print"present worth: ";
  87. 860 ifdc=1then printd$;""
  88. 870 ifdc<>1thenprintc$;""
  89. 880 input"future amount ($): ";f:print
  90. 890 if f=0then goto20
  91. 900 input"interest rate per period (%): ";pr:print
  92. 910 input"time period: ";per
  93. 920 if dc=1 then p=f/((1+pr/100)^per)
  94. 930 ifdc<>1 thenr=(pr/100)
  95. 940 ifdc<>1 then p=f*(exp(r)-1)/(r*exp(r*per))
  96. 950 print"the present worth[160]is"
  97. 960 print "$";p
  98. 970 print"press any key to continue"
  99. 980 geta$:ifa$=""then980
  100. 990 goto20
  101. 1000 rem
  102. 1010 print"sinking fund: ";
  103. 1020 ifdc=1then printd$;""
  104. 1030 ifdc<>1thenprintc$;""
  105. 1040 input"future amount ($): ";f:print
  106. 1050 iff=0thengoto20
  107. 1060 input"interest rate per period (%): ";pr:print
  108. 1070 input"time period: ";per
  109. 1080 if dc=1 then a=(f*(pr)/100)/(((1+pr/100)^per)-1)
  110. 1090 ifdc<>1 thenr=(pr/100)
  111. 1100 ifdc<>1 then a=(f*(pr)/100)/(exp(r*per)-1)
  112. 1110 print"the payments per period are"
  113. 1120 print "$";a
  114. 1130 print"press any key to continue"
  115. 1140 geta$:ifa$=""then1140
  116. 1150 goto20
  117. 1160 rem
  118. 1170 print"series compound: ";
  119. 1180 ifdc=1then printd$;""
  120. 1190 ifdc<>1thenprintc$;""
  121. 1200 input"annuity amount ($): ";a:print
  122. 1210 ifa=0thengoto20
  123. 1220 input"interest rate per period (%): ";pr:print
  124. 1230 input"time period: ";per
  125. 1240 if pr<> 0 then 1280
  126. 1250 print"can't compute: division by zero"
  127. 1260 print"press any key to continue"
  128. 1270 geta$:ifa$=""then1270
  129. 1280 if dc=1 then f=a*((1+pr/100)^per-1)/(pr/100)
  130. 1290 ifdc<>1 then r=(pr/100)
  131. 1300 ifdc<>1 then f=a*(exp(r*per)-1)/r
  132. 1310 print"the future amount is"
  133. 1320 print "$";f
  134. 1330 print"press any key to continue"
  135. 1340 geta$:ifa$=""then1340
  136. 1350 goto20
  137. 1360 rem
  138. 1370 print"capital recovery: ";
  139. 1380 ifdc=1then printd$;""
  140. 1390 ifdc<>1thenprintc$;""
  141. 1400 input"present amount ($): ";p:print
  142. 1410 ifp=0thengoto20
  143. 1420 input"interest rate per period (%): ";pr:print
  144. 1430 input"time period: ";per
  145. 1440 if dc=1 then a=p*((pr/100)*(1+pr/100)^per)/((1+pr/100)^per-1)
  146. 1450 ifdc<>1 then r=(pr/100)
  147. 1460 ifdc<>1 then a=p*r*exp(r*per)/(exp(r*per)-1)
  148. 1470 print"the annuity amount is"
  149. 1480 print "$";a
  150. 1490 print"press any key to continue"
  151. 1500 geta$:ifa$=""then1500
  152. 1510 goto20
  153. 1520 rem
  154. 1530 print"series present worth: ";
  155. 1540 ifdc=1then printd$;""
  156. 1550 ifdc<>1thenprintc$;""
  157. 1560 input"annuity amount ($): ";a:print
  158. 1570 ifa=0thengoto20
  159. 1580 input"interest rate per period (%): ";pr:print
  160. 1590 input"time period: ";per
  161. 1600 if pr<> 0 then 1640
  162. 1610 print"can't compute: division by zero"
  163. 1620 print"press any key to continue"
  164. 1630 geta$:ifa$=""then1630
  165. 1640 if dc=1 then p=a*((1+pr/100)^per-1)/(pr/100*(1+pr/100)^per)
  166. 1650 ifdc<>1 then r=(pr/100)
  167. 1660 ifdc<>1 then p=a*(exp(r*per)-1)/(r*exp(r*per))
  168. 1670 print"the present worth is"
  169. 1680 print "$";p
  170. 1690 print"press any key to continue"
  171. 1700 geta$:ifa$=""then1700
  172. 1710 goto20
  173. 1720 rem
  174. 1730 ifdc=1then1790
  175. 1740 print"arithemtic gradient can't be calculated by this program ";
  176. 1750 print"for a continuous        compounding period."
  177. 1760 print"press any key to continue"
  178. 1770 geta$:ifa$=""then1770
  179. 1780 run
  180. 1790 print"arithmetic gradient: ";
  181. 1800 ifdc=1then printd$;""
  182. 1810 input"uniform increase ($): ";g:print
  183. 1820 ifg=0thengoto20
  184. 1830 input"interest rate per period (%): ";pr:print
  185. 1840 input"time period: ";per
  186. 1850 first=1/(pr/100)
  187. 1860 sec=per/((1+pr/100)^per-1)
  188. 1870 a=g*(first-sec)
  189. 1880 print"the annuity amount is"
  190. 1890 print "$";a
  191. 1900 print"press any key to continue"
  192. 1910 geta$:ifa$=""then1910
  193. 1920 goto20
  194. 1930 rem help routine
  195. 1940 printchr$(147)
  196. 1950 print"[159]";
  197. 1960 print"              ***  help  ***"
  198. 1970 print:print
  199. 1980 print"use the cursor up and down keys to"
  200. 1990 print"highlight an item, and then press"
  201. 2000 print"space to select it."
  202. 2010 print:print"press q to quit, h for this help screen"
  203. 2020 print"or c to toggle the compounding"
  204. 2030 print"method."
  205. 2040 print:print:print:print:print"press any key to continue"
  206. 2050 geta$:ifa$=""then 2050
  207. 2060 goto20:return
  208.